package com.restaurant.springboot.controller;

import com.restaurant.springboot.entity.ShopEntity;
import com.restaurant.springboot.service.ShopService;
import com.restaurant.springboot.utils.RespCode;
import com.restaurant.springboot.utils.RespEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/admin/restaurant")
public class ShopController {

    @Autowired
    private ShopService shopService;

    @GetMapping("")
    public RespEntity getShopMessage() {
            return new RespEntity(RespCode.SUCCESS, shopService.getShopMessage().orElse(new ShopEntity()));
    }

    @PutMapping("")
    public RespEntity updateShopMessage(@RequestBody ShopEntity shop) {
        // 默认商店id为1
        shop.setId(1);
        if(shopService.updateShopMessage(shop)){
            return new RespEntity(RespCode.SUCCESS);
        }else{
            return new RespEntity(RespCode.ERROR,"modify fail",null);
        }
    }

}
